package com.seveneight.baijiesteward.views;

import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import com.flyco.dialog.listener.OnOperItemClickL;
import com.flyco.dialog.widget.ActionSheetDialog;
import com.seveneight.baijiesteward.base.MessageBean;
import com.seveneight.baijiesteward.bean.BranchBean;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

/**
 * Created by user1 on 2018/4/14.
 */

public class BranchBankListDialog {

    private List<BranchBean> data;
    private Context context;
    private ActionSheetDialog dialog;
    private BranchBean branchBean;
    private int type;

    public BranchBankListDialog(Context context, int type, List<BranchBean> data) {
        this.data = data;
        this.type = type;
        this.context = context;
        getBankList();
    }


    public void getBankList() {
        final String[] stringItems = new String[data.size()];
        for (int i = 0; i < data.size(); i++) {
            stringItems[i] = data.get(i).getText();
        }
        dialog = new ActionSheetDialog(context, stringItems, null);
        dialog.setOnOperItemClickL(new OnOperItemClickL() {
            @Override
            public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                branchBean = data.get(position);
                EventBus.getDefault().post(new MessageBean(type, branchBean));
                dialog.dismiss();
            }
        });
    }

    public void show() {
        dialog.show();
    }
}
